{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "051d99c8",
   "metadata": {},
   "source": [
    "---\n",
    "· 日期：2022-10-12\\week08(周三)\n",
    "\n",
    "· 课程：python\n",
    "\n",
    "· 记录人：林荣烽\n",
    "\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "52336a42",
   "metadata": {},
   "source": [
    "# 本周知识点\n",
    "\n",
    "> 1. 有序的数据结构-字符串\n",
    "\n",
    ">> 1. 字符串的基本概念（回顾）\n",
    ">>> 1. Single quotes: 'allows embedded \"double\" quotes'\n",
    ">>> 2. Double quotes: \"allows embedded 'single' quotes\"\n",
    ">>> 3. Triple quoted: '''Three single quotes''', \"\"\"Three double quotes\"\"\"\n",
    ">> 2. 字符串的性质和方法\n",
    "\n",
    "> 2. 有序的数据结构-列表"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c1d0277d",
   "metadata": {},
   "source": [
    "## 1.字符串的性质和方法\n",
    "\n",
    "* 字符串的性质\n",
    "> 1. 字符串的有序性\n",
    "> 2. 字符串是有长度的\n",
    ">> 1.使用len()检查字符串的长度\n",
    "\n",
    "* 字符串的基础方法 (运算法则)\n",
    "> 1. 字符串的取值: str[index]\n",
    "> 2. 字符串的切片: str[start,stop],stop取不到\n",
    "> 3. 字符串的拼接: +\n",
    "> 4. in 检查成员是否存在\n",
    "\n",
    "* 字符串的一般方法 （function/Methods 函数/方法）\n",
    "> 1. isdigit()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a112a981",
   "metadata": {},
   "outputs": [],
   "source": [
    "text = \"广州南方学院团委\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3207ddf0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c232b861",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'州'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "237776b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'委'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "598465c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'团'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[-2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "cf2e5faa",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "string index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-6-c8b5ecea273b>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mtext\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m100\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m: string index out of range"
     ]
    }
   ],
   "source": [
    "text[100]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "e7c58178",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "b8a78098",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0] + text[1] + text[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "270c13cc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0:6] # 等价于 text[:6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "77dc7803",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[:6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "8bfecb70",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[-1:-3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "03d71324",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'院团'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[-3:-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "b09845d0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'团委'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[-2:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "6dcd9330",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院团委广州南方学院团委广州南方学院团委'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3 * text"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "35a03ad1",
   "metadata": {},
   "source": [
    "* in 检查成员对象\n",
    "* count()检查字符串出现的次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "eea979b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"广州\" in text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "eb322050",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"北京\" in text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "48020307",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3 * text.count(\"广州\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2e72e81c",
   "metadata": {},
   "source": [
    "* isdigit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "d8e4b879",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19\n",
      "19\n"
     ]
    }
   ],
   "source": [
    "print(19)\n",
    "print(\"19\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "0c0b27aa",
   "metadata": {},
   "outputs": [],
   "source": [
    "age_1 = 19\n",
    "age_2 = \"19\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "4f867c80",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19 <class 'int'>\n",
      "19 <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(age_1,type(age_1))\n",
    "print(age_2,type(age_2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "73a05671",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 如果字符串是数值，可以用int转换成真正的数值\n",
    "if age_2.isdigit():\n",
    "    print(age_1 + int(age_2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "854902f5",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for +: 'int' and 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-23-69e73c6baa3a>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mage_1\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mage_2\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'"
     ]
    }
   ],
   "source": [
    "age_1 + age_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "fe172538",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "age_2.isdigit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "157721ba",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = \"Jack\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "dcca2eea",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "invalid literal for int() with base 10: 'Jack'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-28-f75bcf899621>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: 'Jack'"
     ]
    }
   ],
   "source": [
    "int(name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "63f3b4e3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "38"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "age_1 + int(age_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "d1fec68c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "38\n"
     ]
    }
   ],
   "source": [
    "if age_2.isdigit():\n",
    "    print(age_1 + int(age_2))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bb7a000e",
   "metadata": {},
   "source": [
    "## 2.有序的数据结构-列表（List）\n",
    "\n",
    "* 1. 列表的概念和基本性质\n",
    "> Python knows a number of compound data types, used to group together other values. The most versatile is the list, which can be written as a list of comma-separated values (items) between square brackets. Lists might contain items of different types, but usually the items all have the same type.\n",
    "\n",
    "* 2. 列表一般方法（如何学习）\n",
    "> 1. 增加\n",
    "> 2. 删除\n",
    "> 3. 改\n",
    "> 4. 查 ：in\n",
    "* 列表的学习方法（步骤）\n",
    "> 1. 使用.Tab键查看列表的方法\n",
    "> 2. 使用help（查看方法的使用规则）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "347982b3",
   "metadata": {},
   "source": [
    "### 2.1 列表的性质\n",
    "\n",
    "* 和字符串的运算法则完全一致\n",
    "* 注意：字符串是对字符进行操作，列表是对items元素进行操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "2ff1500f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 9, 16, 25]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 列表的形式\n",
    "squares = [1, 4, 9, 16, 25] # 列表里面放数值\n",
    "squares"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "bedf87e4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "25"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "squares[4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "088fe032",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "4 in squares"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "48bde791",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "squares.count(9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "408eaac0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan']"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names = [\"Jack\",\"Alex\",\"Marry\",\"Jan\"] # 列表里面放字符串\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "31229780",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 9, 16, 25, 'Jack', 'Alex', 'Marry', 'Jan']"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "squares + names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "88061d5d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 9, 16, 25, 1, 4, 9, 16, 25]"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2*squares"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "616ca89f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Alex', 'Marry']"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names[1:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "f34f4dc6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Marry', 'Jan']"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names[-2:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "c6528488",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Marry']"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 取出\"Jack\",\"Marry\" 用切片的方法\n",
    "names[:3:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "80bddc41",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 18, '李华', 20]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "info = [\"Jack\",18,\"李华\",20]\n",
    "info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "ab7b5788",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan']"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names = [\"Jack\",\"Alex\",\"Marry\",\"Jan\"]\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "c39bcbb3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "11e98871",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(\"Lihua\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "8ca3cf28",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 'Lihua']"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names # 列表是有序的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b2f6782b",
   "metadata": {},
   "source": [
    "# 课后作业\n",
    "\n",
    "* 列表的方法 尝试所有的方法\n",
    "* 总结列表的方法学习心得（表格形式总结）\n",
    " \n",
    "|  列表的方法 |  Description  |     使用方法    |      备注     |\n",
    "| ----------  | ------------------| ------------------- | ----------------- |\n",
    "|  append  |   Append object to the end of the list.  | list.append(object) | 注意：增加在末尾！|\n",
    "|  clear  |    Remove all items from list.| list.clear(self)| 注意：将元素清空|\n",
    "|  copy   |   Return a shallow copy of the list.   | list.copy(self)  |注意：不等价于 = |\n",
    "|  count   |  Return number of occurrences of value. | list.count(self,value)  | 注意：返回的是某个元素在列表里面的个数 |\n",
    "|  extend  |  Extend list by appending elements from the iterable.  | list.extend(self, iterable) | 注意：在list的末尾添加元素 |\n",
    "|  index   | Return first index of value.  | list.index(self, value)  | 注意：返回的是元素在列表中的第一个位置 |\n",
    "|  insert  | Insert object before index.   | list.insert(self, index, object)   |注意： 向指定的地方添加元素 |\n",
    "|  pop   |  Remove and return item at index (default last). | list.pop(self, index=-1)  |注意：删除列表尾部的元素,返回删除的元素 |\n",
    "|  remove |  Remove first occurrence of value. | list.remove(self, value) | 注意：删除的是第一次出现的元素，如果元素不存在会报错  |\n",
    "|  reverse  | Reverse *IN PLACE*.    | list.reverse(self) | 注意：将列表进行翻转  |\n",
    "|  sort    | Sort the list in ascending order and return None. |list.sort(self)|注意：对列表进行排序，反向标志可以设置为按降序排序 |"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "1785f63b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method_descriptor:\n",
      "\n",
      "append(self, object, /)\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(list.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "0a020e69",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method_descriptor:\n",
      "\n",
      "clear(self, /)\n",
      "    Remove all items from list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(list.clear)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "89c9983f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method_descriptor:\n",
      "\n",
      "copy(self, /)\n",
      "    Return a shallow copy of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(list.copy)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "75de0bd1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method_descriptor:\n",
      "\n",
      "count(self, value, /)\n",
      "    Return number of occurrences of value.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(list.count)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "bf6d73a4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method_descriptor:\n",
      "\n",
      "extend(self, iterable, /)\n",
      "    Extend list by appending elements from the iterable.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(list.extend)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "ec3d7982",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method_descriptor:\n",
      "\n",
      "index(self, value, start=0, stop=9223372036854775807, /)\n",
      "    Return first index of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(list.index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "78831c0f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method_descriptor:\n",
      "\n",
      "insert(self, index, object, /)\n",
      "    Insert object before index.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(list.insert)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "00f2bc0d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method_descriptor:\n",
      "\n",
      "pop(self, index=-1, /)\n",
      "    Remove and return item at index (default last).\n",
      "    \n",
      "    Raises IndexError if list is empty or index is out of range.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(list.pop)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "241c775d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method_descriptor:\n",
      "\n",
      "remove(self, value, /)\n",
      "    Remove first occurrence of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(list.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "db12f428",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method_descriptor:\n",
      "\n",
      "reverse(self, /)\n",
      "    Reverse *IN PLACE*.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(list.reverse)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "03871e0e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method_descriptor:\n",
      "\n",
      "sort(self, /, *, key=None, reverse=False)\n",
      "    Sort the list in ascending order and return None.\n",
      "    \n",
      "    The sort is in-place (i.e. the list itself is modified) and stable (i.e. the\n",
      "    order of two equal elements is maintained).\n",
      "    \n",
      "    If a key function is given, apply it once to each list item and sort them,\n",
      "    ascending or descending, according to their function values.\n",
      "    \n",
      "    The reverse flag can be set to sort in descending order.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(list.sort)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "6592a005",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan']"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names = [\"Jack\",\"Alex\",\"Marry\",\"Jan\"]\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "59b5e8f4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 'Lihua']"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.append(\"Lihua\")\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "156413e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.clear()\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "d2df56e3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan']"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names = [\"Jack\",\"Alex\",\"Marry\",\"Jan\"]\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "a1982743",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan']"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.copy()\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "d67191e7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan']"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.count(\"names\")\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "9a2d36b4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 'L', 'i', 'h', 'u', 'a']"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.extend(\"Lihua\")\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "58a3d5d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 'L', 'i', 'h', 'u', 'a']"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.index(\"Alex\")\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "4220f808",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 'L', 'i', 'h', 'u']"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.pop()\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "4fa25a3e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 2009, 'L', 'i', 'h', 2022, 'u']"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.insert( 8,2022)\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "370656ed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 'L', 'i', 'h', 2022, 'u']"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.remove(2009)\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "768c10b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Alex', 'Jack', 'Jan', 'L', 'Marry', 'h', 'i', 'u']"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.remove(2022)\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "922d5243",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['2', '3', '7', '1']"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names = [\"2\",\"3\",\"7\",\"1\"]\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "74777ce3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['1', '2', '3', '7']"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.sort()\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cec61263",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
